import sys

class Solution(object):
    def summaryRanges(self, nums):
        """
        :type nums: List[int]
        :rtype: List[str]
        """
        result = []
        lastNum = sys.maxsize
        begin = sys.maxsize
        end = sys.maxsize

        for num in nums:
            if num==lastNum+1:
                end=num
            else:
                result.append((begin, end))
                begin = num
                end = num
            lastNum = num
        result.append((begin, end))
        result.pop(0)
        def func(pair):
            if pair[0]==pair[1]:
                return str(pair[0])
            else:
                return "{}->{}".format(pair[0], pair[1])
        return [func(pair) for pair in result]
    
print(Solution().summaryRanges([0,1,2,4,5,7]))